﻿//JumbotCms_4.1 Final
using System;
using System.Data;
using System.Web;
using Jumbot.Common;
using Jumbot.DataOper;
namespace JumbotCms.DataObject
{
    /// <summary>
    /// 管理员表信息
    /// </summary>
    public class Admin
    {
        private string m_AdminId = "0";
        private string m_AdminName = string.Empty;
        private string m_AdminFolder = string.Empty;
        private string m_AdminPass = string.Empty;
        private string m_Setting = string.Empty;
        private DateTime m_LastTime2 = DateTime.Now;
        private string m_LastIP2 = string.Empty;
        private string m_Cookiess = string.Empty;
        private int m_AdminState = 0;

        public string AdminId
        {
            get { return m_AdminId; }
            set { m_AdminId = value; }
        }
        public string AdminName
        {
            set { m_AdminName = value; }
            get { return m_AdminName; }
        }
        public string AdminFolder
        {
            set { m_AdminFolder = value; }
            get { return m_AdminFolder; }
        }
        public string AdminPass
        {
            set { m_AdminPass = value; }
            get { return m_AdminPass; }
        }
        public string Setting
        {
            set { m_Setting = value; }
            get { return m_Setting; }
        }
        public DateTime LastTime2
        {
            set { m_LastTime2 = value; }
            get { return m_LastTime2; }
        }
        public string LastIP2
        {
            set { m_LastIP2 = value; }
            get { return m_LastIP2; }
        }
        public string Cookiess
        {
            set { m_Cookiess = value; }
            get { return m_Cookiess; }
        }
        public int AdminState
        {
            set { m_AdminState = value; }
            get { return m_AdminState; }
        }

        public Admin()
        {}
        public void GetAllColumn(string _adminid, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT AdminId,AdminName,AdminFolder,AdminPass,Setting,LastTime2,LastIP2,Cookiess,AdminState FROM [jcms_normal_user] WHERE [AdminId]=" + _adminid;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                DataRow dr = dt.Rows[0];
                AdminId = _adminid;
                AdminName = dr["AdminName"].ToString();
                AdminFolder = dr["AdminFolder"].ToString();
                AdminPass = dr["AdminPass"].ToString();
                Setting = dr["Setting"].ToString();
                LastTime2 = Validator.StrToDate(dr["LastTime2"].ToString(), DateTime.Now);
                LastIP2 = dr["LastIP2"].ToString();
                Cookiess = dr["Cookiess"].ToString();
                AdminState = Validator.StrToInt(dr["AdminState"].ToString(), 0);
            }
        }

        public string GetAdminName(string _adminid, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT [AdminName] FROM [jcms_normal_user] WHERE [AdminId]=" + _adminid;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                return dt.Rows[0]["AdminName"].ToString();
            }
            return string.Empty;
        }
        public string GetAdminFolder(string _adminid, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT [AdminFolder] FROM [jcms_normal_user] WHERE [AdminId]=" + _adminid;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                return dt.Rows[0]["AdminFolder"].ToString();
            }
            return string.Empty;
        }
        public string GetAdminPass(string _adminid, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT [AdminPass] FROM [jcms_normal_user] WHERE [AdminId]=" + _adminid;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                return dt.Rows[0]["AdminPass"].ToString();
            }
            return string.Empty;
        }
        public DateTime GetRegtime(string _adminid, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT [Regtime] FROM [jcms_normal_user] WHERE [AdminId]=" + _adminid;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                return Validator.StrToDate(dt.Rows[0]["Regtime"].ToString(), DateTime.Now);
            }
            return DateTime.Now;
        }
        public string GetQuestion(string _adminid, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT [Question] FROM [jcms_normal_user] WHERE [AdminId]=" + _adminid;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                return dt.Rows[0]["Question"].ToString();
            }
            return string.Empty;
        }
        public string GetAnswer(string _adminid, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT [Answer] FROM [jcms_normal_user] WHERE [AdminId]=" + _adminid;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                return dt.Rows[0]["Answer"].ToString();
            }
            return string.Empty;
        }
        public string GetSetting(string _adminid, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT [Setting] FROM [jcms_normal_user] WHERE [AdminId]=" + _adminid;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                return dt.Rows[0]["Setting"].ToString();
            }
            return string.Empty;
        }
        public DateTime GetLastTime2(string _adminid, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT [LastTime2] FROM [jcms_normal_user] WHERE [AdminId]=" + _adminid;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                return Validator.StrToDate(dt.Rows[0]["LastTime2"].ToString(), DateTime.Now);
            }
            return DateTime.Now;
        }
        public string GetLastIP2(string _adminid, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT [LastIP2] FROM [jcms_normal_user] WHERE [AdminId]=" + _adminid;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                return dt.Rows[0]["LastIP2"].ToString();
            }
            return string.Empty;
        }
        public string GetCookiess(string _adminid, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT [Cookiess] FROM [jcms_normal_user] WHERE [AdminId]=" + _adminid;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                return dt.Rows[0]["Cookiess"].ToString();
            }
            return string.Empty;
        }
        public int GetAdminState(string _adminid, DbOperHandler doh)
        {
            doh.Reset();
            doh.SqlCmd = "SELECT [AdminState] FROM [jcms_normal_user] WHERE [AdminId]=" + _adminid;
            DataTable dt = doh.GetDataTable();
            if (dt.Rows.Count > 0)
            {
                return Validator.StrToInt(dt.Rows[0]["AdminState"].ToString(), 0);
            }
            return 0;
        }

    }
}
